#{extends 'main.html' /}
#{set title:'Meu Cafofo' /}
#{set 'moreScripts'}
	<script type="text/javascript">
	$(document).ready(function(){
		var actionCidades = #{jsAction @Cidades.listarCidadeByEstado(':estado') /}
		var actionBairros = #{jsAction @Bairros.listarBairroByCidade(':cidade')/}
		
		
		$('#cmb_estado').change(function(){
			
			
			$.get(actionCidades({estado: $('#cmb_estado').val()}), function(data){
				$('#cmb_cidade').html(data);
			});
			
		});	
		
		$('#cmb_cidade').live('change',function(){
			$.get(actionBairros({cidade: $('#cmb_cidade').val()}), function(data){
				$('#cmb_bairro').html(data);
			});
			
		});	
	});
	</script>
	<script type="text/javascript">
	$(document).ready(function()){
	
	});
	</script>
#{/set}
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" lang="pt-BR">

  <head>
  <meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
  

<title>Busca Avançada</title>

<body>

    <div class="buscaAvancada" >
		<form  action="@{Imovels.buscarImovel()}" method="post" >
        
  		#{field 'imovel.transacao'}
          <div style="float: left; padding-right:50px;" class="control-group ${errors.forKey(field.name)?'error':''} ">
          <label for="${field.name}" class="control-label">Transação do Imóvel</label>
            <div class="controls">
              <Select name="${field.name}.id" value="${field.value}" class="input-large">
             	<option value="-1" selected="selected">Selecione</option>
				#{list transacao, as:'tran'}
                <option value="${tran.id}">${tran.descricao}</option>
           		#{/list}
              </Select>
              <span class="help-inline">${errors.forKey(field.name)}</span>
            </div>
          </div>
          #{/field}  
                
          #{field 'imovel.tipoImovel'}
          <div style="float: left; padding-right:50px;" class="control-group ${errors.forKey(field.name)?'error':''}">
          <label for="${field.name}" class="control-label">Tipo do Imóvel</label>
            <div class="controls">
              <Select name="${field.name}.id" value="${field.value}" class="input-large">
             	<option value="-1" selected="selected">Selecione</option>
				#{list tipoImovel, as:'ti'}
                <option value="${ti.id}">${ti.descricao}</option>
           		#{/list}
              </Select>
              <span class="help-inline">${errors.forKey(field.name)}</span>
            </div>
          </div>
          #{/field}
          #{field 'imovel.quartos'}
          <div style="float: left; padding-right:50px;" class="control-group ${errors.forKey(field.name)?'error':''}">
          <label for="${field.name}" class="control-label">Qtd. Quartos</label>
            <div class="controls">
              <Select type="text" name="${field.name}" value="${field.value}" class="input-large">
             	<option value="-1" selected="selected">Selecione</option>
             	<option value="1">1</option>
                <option value="2">2</option>
                <option value="3">3</option>
                <option value="4">4</option>
                <option value="5">5</option>
                <option value="6">6+</option>
              </Select>
              <span class="help-inline">${errors.forKey(field.name)}</span>
            </div>
          </div>
        <div style="clear:both;"></div> 
          #{/field}
          #{field 'imovel.estado'}
          <div style="float: left; padding-right:50px;" class="control-group ${errors.forKey(field.name)?'error':''}">
          <label for="${field.name}" class="control-label">Estado</label>
            <div class="controls">
              <Select name="${field.name}.id" id="cmb_estado" value="${field.value}" class="input-large">
             	<option value="-1" selected="selected">Selecione</option>
				#{list estado, as:'est'}
                <option value="${est.id}">${est.descricao}</option>
           		#{/list}
              </Select>
              <span class="help-inline">${errors.forKey(field.name)}</span>
            </div>
          </div>
          #{/field}
          
          #{field 'imovel.cidade'}
          <div style="float: left; padding-right:50px;" class="control-group ${errors.forKey(field.name)?'error':''}">
          <label for="${field.name}" class="control-label">Cidade</label>
            <div class="controls">
              <Select name="${field.name}.id" value="${field.value}" id="cmb_cidade" class="input-large">
             	<option value="-1" selected="selected">Selecione</option>

              </Select>
              <span class="help-inline">${errors.forKey(field.name)}</span>
            </div>
          </div>
          #{/field}
          
          #{field 'imovel.bairro'}
          <div style="float: left; padding-right:50px;" class="control-group ${errors.forKey(field.name)?'error':''}">
          <label for="${field.name}" class="control-label">Bairro</label>
            <div class="controls">
              <Select name="${field.name}.id" value="${field.value}" id="cmb_bairro" class="input-large">
             	<option value="-1" selected="selected">Selecione</option>
             </Select>
              <span class="help-inline">${errors.forKey(field.name)}</span>
            </div>
          </div>
          <div style="clear:both;"></div>
          
          #{/field}
          	<input  class="btn btn-medium" type="submit" value="Busca Avançada"/>
          </form>
    </div>
		   <div class="row-fluid" style="float: left;">
          #{if imovels}
           #{list imovels.size()>5?imovels[0..4]:imovels,as:'imovel'}
            <div class="span2_3 pull-center well">
            <h4>Ref: ${imovel.id}</h4>
				<img src="@{imovels.mostrarFoto1(imovel.id)}" width="100px"/><br /><br />
              		<a class="btn btn-small" href="@{imovels.mostrar(imovel.id)}">Ver imóvel &raquo;</a>
              	
            	</div><!--/span-->
            #{/list}
            #{/if}
            #{else}
            	<p>Não há Imóveis para exibir</p>
            #{/else}
          </div><!--/row-->
          
          </div>

</body>
</html>